gtk_container_remove
gtk_container_foreach
gtk_container_get_children
-gtk_container_get_path_for_child
gtk_container_get_focus_vadjustment
gtk_container_set_focus_vadjustment
gtk_container_get_focus_hadjustment
GtkCallback callback,
gpointer callback_data);
static GType gtk_box_child_type (GtkContainer *container);
-static GtkWidgetPath * gtk_box_get_path_for_child
- (GtkContainer *container,
- GtkWidget *child);
G_DEFINE_TYPE_WITH_CODE (GtkBox, gtk_box, GTK_TYPE_CONTAINER,
G_ADD_PRIVATE (GtkBox)
container_class->remove = gtk_box_remove;
container_class->forall = gtk_box_forall;
container_class->child_type = gtk_box_child_type;
- container_class->get_path_for_child = gtk_box_get_path_for_child;
g_object_class_override_property (object_class,
PROP_ORIENTATION,
return GTK_TYPE_WIDGET;
}
-typedef struct _CountingData CountingData;
-struct _CountingData {
- GtkWidget *widget;
- gboolean found;
- guint before;
- guint after;
-};
-
-static void
-count_widget_position (GtkWidget *widget,
- gpointer data)
-{
- CountingData *count = data;
-
- if (!_gtk_widget_get_visible (widget))
- return;
-
- if (count->widget == widget)
- count->found = TRUE;
- else if (count->found)
- count->after++;
- else
- count->before++;
-}
-
-static gint
-gtk_box_get_visible_position (GtkBox *box,
- GtkWidget *child)
-{
- CountingData count = { child, FALSE, 0, 0 };
- GtkBoxPrivate *priv = gtk_box_get_instance_private (box);
-
- /* foreach iterates in visible order */
- gtk_container_foreach (GTK_CONTAINER (box),
- count_widget_position,
- &count);
-
- /* the child wasn't found, it's likely an internal child of some
- * subclass, return -1 to indicate that there is no sibling relation
- * to the regular box children
- */
- if (!count.found)
- return -1;
-
- if (priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
- gtk_widget_get_direction (GTK_WIDGET (box)) == GTK_TEXT_DIR_RTL)
- return count.after;
- else
- return count.before;
-}
-
-static GtkWidgetPath *
-gtk_box_get_path_for_child (GtkContainer *container,
- GtkWidget *child)
-{
- GtkWidgetPath *path, *sibling_path;
- GtkBox *box = GTK_BOX (container);
- GtkBoxPrivate *priv = gtk_box_get_instance_private (box);
- GList *list, *children;
-
- path = _gtk_widget_create_path (GTK_WIDGET (container));
-
- if (_gtk_widget_get_visible (child))
- {
- gint position;
-
- sibling_path = gtk_widget_path_new ();
-
- /* get_children works in visible order */
- children = gtk_container_get_children (container);
- if (priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
- _gtk_widget_get_direction (GTK_WIDGET (box)) == GTK_TEXT_DIR_RTL)
- children = g_list_reverse (children);
-
- for (list = children; list; list = list->next)
- {
- if (!_gtk_widget_get_visible (list->data))
- continue;
-
- gtk_widget_path_append_for_widget (sibling_path, list->data);
- }
-
- g_list_free (children);
-
- position = gtk_box_get_visible_position (box, child);
-
- if (position >= 0)
- gtk_widget_path_append_with_siblings (path, sibling_path, position);
- else
- gtk_widget_path_append_for_widget (path, child);
-
- gtk_widget_path_unref (sibling_path);
- }
- else
- gtk_widget_path_append_for_widget (path, child);
-
- return path;
-}
-
static void
gtk_box_init (GtkBox *box)
{
gpointer client_data);
static GtkSizeRequestMode gtk_container_get_request_mode (GtkWidget *widget);
-static GtkWidgetPath * gtk_container_real_get_path_for_child (GtkContainer *container,
- GtkWidget *child);
-
/* GtkBuildable */
static void gtk_container_buildable_init (GtkBuildableIface *iface);
static GtkBuildableIface *parent_buildable_iface;
class->forall = NULL;
class->set_focus_child = gtk_container_real_set_focus_child;
class->child_type = NULL;
- class->get_path_for_child = gtk_container_real_get_path_for_child;
container_signals[ADD] =
g_signal_new (I_("add"),
}
}
-static GtkWidgetPath *
-gtk_container_real_get_path_for_child (GtkContainer *container,
- GtkWidget *child)
-{
- GtkWidgetPath *path;
-
- path = _gtk_widget_create_path (GTK_WIDGET (container));
- gtk_widget_path_append_for_widget (path, child);
-
- return path;
-}
-
static void
gtk_container_children_callback (GtkWidget *widget,
gpointer client_data)
return hadjustment;
}
-/**
- * gtk_container_get_path_for_child:
- * @container: a #GtkContainer
- * @child: a child of @container
- *
- * Returns a newly created widget path representing all the widget hierarchy
- * from the toplevel down to and including @child.
- *
- * Returns: A newly created #GtkWidgetPath
- **/
-GtkWidgetPath *
-gtk_container_get_path_for_child (GtkContainer *container,
- GtkWidget *child)
-{
- GtkWidgetPath *path;
-
- g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
- g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
- g_return_val_if_fail (container == (GtkContainer *) _gtk_widget_get_parent (child), NULL);
-
- path = GTK_CONTAINER_GET_CLASS (container)->get_path_for_child (container, child);
- if (gtk_widget_path_get_object_type (path) != G_OBJECT_TYPE (child))
- {
- g_critical ("%s %p returned a widget path for type %s, but child is %s",
- G_OBJECT_TYPE_NAME (container),
- container,
- g_type_name (gtk_widget_path_get_object_type (path)),
- G_OBJECT_TYPE_NAME (child));
- }
-
- return path;
-}
* @child_type: Returns the type of the children supported by the container.
* @set_child_property: Set a property on a child of container.
* @get_child_property: Get a property from a child of container.
- * @get_path_for_child: Get path representing entire widget hierarchy
- * from the toplevel down to and including @child.
*
* Base class for containers.
*/
void (*set_focus_child) (GtkContainer *container,
GtkWidget *child);
GType (*child_type) (GtkContainer *container);
- GtkWidgetPath * (*get_path_for_child) (GtkContainer *container,
- GtkWidget *child);
/*< private >*/
GtkCallback callback,
gpointer callback_data);
-GDK_AVAILABLE_IN_ALL
-GtkWidgetPath * gtk_container_get_path_for_child (GtkContainer *container,
- GtkWidget *child);
-
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkContainer, g_object_unref)
G_END_DECLS
* Updates the style context of @widget and all descendants
* by updating its widget path. #GtkContainers may want
* to use this on a child when reordering it in a way that a different
- * style might apply to it. See also gtk_container_get_path_for_child().
+ * style might apply to it.
*/
void
gtk_widget_reset_style (GtkWidget *widget)
{
GtkWidget *parent = _gtk_widget_get_parent (widget);
- if (parent && GTK_IS_CONTAINER (parent))
- return gtk_container_get_path_for_child (GTK_CONTAINER (parent), widget);
- else if (parent)
+ if (parent)
{
GtkWidgetPath *path = _gtk_widget_create_path (parent);
gtk_widget_path_append_for_widget (path, widget);